/*
 * @Author: master
 * @Date: 2021-12-01 16:37:25
 * @LastEditTime: 2021-12-01 17:24:53
 * @Description: 浏览器窗口服务
 */
/**
 * 进入全屏
 */
export const toFullScreen = () => {
  const el = document.documentElement;
  const rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullScreen;
  if (typeof rfs !== 'undefined' && rfs) {
    rfs.call(el);
  } else if (typeof window.ActiveXObject !== 'undefined') {
    // for IE，这里其实就是模拟了按下键盘的F11，使浏览器全屏
    // eslint-disable-next-line no-undef
    const wscript = new ActiveXObject('WScript.Shell');
    if (wscript != null) {
      wscript.SendKeys('{F11}');
    }
  }
};
/**
 * 退出全屏
 */
export const exitFullScreen = () => {
  const el = document;
  const cfs = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullScreen;
  if (typeof cfs !== 'undefined' && cfs) {
    cfs.call(el);
  } else if (typeof window.ActiveXObject !== 'undefined') {
    // for IE，这里和fullScreen相同，模拟按下F11键退出全屏
    // eslint-disable-next-line no-undef
    const wscript = new ActiveXObject('WScript.Shell');
    if (wscript != null) {
      wscript.SendKeys('{F11}');
    }
  }
};
/**
 * 判断当前是否为全屏
 */
export const isFullscreenForNoScroll = () => {
  const explorer = window.navigator.userAgent.toLowerCase();
  if (explorer.indexOf('chrome') > 0) {
    // webkit
    return document.body.scrollHeight === window.screen.height && document.body.scrollWidth === window.screen.width;
  } else {
    // IE 9+  fireFox
    return window.outerHeight === window.screen.height && window.outerWidth === window.screen.width;
  }
};
